package com.owen.elasticsearch.service.impl;

import com.owen.elasticsearch.entity.Index;
import com.owen.elasticsearch.repositorie.IndexRepositorie;
import com.owen.elasticsearch.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("indexService")
public class IndexServiceImpl implements IndexService {

    @Autowired
    private IndexRepositorie indexRepositorie;

    @Override
    public Index save(Index index) {
        return indexRepositorie.save(index);
    }

    @Override
    public Index update(Index index) {
        return indexRepositorie.save(index);
    }

    @Override
    public Index delete(String id) {
        Index index = this.findById(id);
        indexRepositorie.delete(index);
        return index;
    }

    @Override
    public Index findById(String id) {
        return indexRepositorie.findById(id).get();
    }
}
